package com.example.mpd.mapper;

import com.example.mpd.entity.Order;
import com.example.mpd.entity.User;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface OrderMapper {
    @Select("select * from theOrder where uid=#{uid}")
    public List<Order> selectByUid(int uid);
    //查询所有用户及其订单
    @Select("select * from theOrder")
    @Results(
            {
                    @Result(column = "id", property = "id"),
                    @Result(column = "orderTime", property = "orderTime"),
                    @Result(column = "total", property = "total"),
                    @Result(column = "uid", property = "user", javaType = User.class,
                            one = @One(select = "com.example.mpd.mapper.UserMapper.findById")
                    )
            }
    )
    public List<Order> findAllOrderAndUser();

}
